import React, { useEffect, useState, useRef } from "react";
import { Form, Input, Button, Row, Col, Space } from 'antd';
import { useHistory, useLocation } from 'dw-mx-router';
import './style/dataSource.css';

export default function DataSourceBasicInfos(props) {

    const { Search } = Input;
    const history = useHistory();
    const [linkText, setLinkText] = useState('');


    useEffect(() => {
    }, []);

    //关键字搜索
    const keywordSearch = (val) => {
        alert(val);
    };

    //点击树节点
    const selectTreeNode = (node, e) => {
        console.log(node);
        console.log(e);
        setLinkText(e.node.title);
    };

    const layout = {
        labelCol: { span: 8 },
        wrapperCol: { span: 16 },
    };
    const tailLayout = {
        wrapperCol: { offset: 8, span: 16 },
    };


    const onFinish = (values: any) => {
        console.log('Success:', values);
    };

    const onFinishFailed = (errorInfo: any) => {
        console.log('Failed:', errorInfo);
    };

    return (
        <>
            <Form
                {...layout}
                name="basic"
                initialValues={{ remember: true }}
                onFinish={onFinish}
                onFinishFailed={onFinishFailed}
            >
                <Row>
                    <Col span={3}/>
                    <Col span={8}>
                        <Form.Item label="名称" name="name">
                            <Input />
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Form.Item label="类型" name="type">
                            <Input />
                        </Form.Item>
                    </Col>
                </Row>
                <Row>
                    <Col span={3}/>
                    <Col span={8}>
                        <Form.Item label="测试地址" name="testAddress">
                            <Input />
                        </Form.Item>
                    </Col>
                    <Col span={8}>
                        <Form.Item label="生产地址" name="produceAddress">
                            <Input />
                        </Form.Item>
                    </Col>
                </Row>
                <Row>
                    <Col span={3}/>
                    <Col span={8}>
                        <Form.Item label="备注" name="testAddress">
                            <Input.TextArea />
                        </Form.Item>
                    </Col>
                </Row>
                <br />
                <div style={{textAlign: 'center', marginTop: '50'}}>
                    <Col span={3}/>
                    <Space size={40}>
                        <Button>测试</Button>
                        <Button>编辑</Button>
                        <Button>删除</Button>
                    </Space>
                </div>
                {/*<Form.Item {...tailLayout}>
                    <Button htmlType="submit">
                        Submit
                    </Button>
                </Form.Item>*/}
            </Form>
        </>
    );
}